﻿Public Class frmRechFour

    Private Sub frmRechFour_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        frmServicesFrn.Enabled = True
    End Sub

    Private Sub frmRechFour_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            remplirLstFourGnrl()
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub

    Private Sub txtRech_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRech.TextChanged
        lstViwFour.Items.Clear()
        Try
            If Not String.IsNullOrWhiteSpace(txtRech.Text) And Not String.IsNullOrEmpty(txtRech.Text) Then

                Dim enregi As String 'Récupère une ligne entier de la liste
                Dim t() As Integer 'stock les id des parain trouvé

                Dim i As Integer = 0 ' le nombre de cases pour la table des fournisseurs trouvé
                For Each fourn In lstFournisseurGnlr
                    If fourn.type = "Matériel" Then
                        enregi = fourn.nom & " " & fourn.prenom & " " & fourn.adrss & " " & _
                        fourn.email & " " & fourn.nomEntrp & " " & fourn.type

                        If enregi.IndexOf(txtRech.Text, 0, enregi.Length, StringComparison.CurrentCultureIgnoreCase) > -1 Then
                            Dim Line As ListViewItem = New ListViewItem(New String() {fourn.idFr, fourn.nom & " " & fourn.prenom, fourn.type})
                            lstViwFour.Items.Add(Line)
                        End If
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub

    Private Sub lstViwFour_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstViwFour.DoubleClick
        Try
            idFournGnlr = CInt(lstViwFour.SelectedItems(0).SubItems(0).Text)
            For Each it As DictionaryEntry In frmServicesFrn.cmbFour.Items
                If it.Key = idFournGnlr Then
                    frmServicesFrn.cmbFour.SelectedItem = it
                    idFournGnlr = 0
                    Exit For
                End If
            Next
            Me.Close()
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub
End Class